﻿//https://leetcode.cn/problems/yong-liang-ge-zhan-shi-xian-dui-lie-lcof/submissions/602407820/?envType=problem-list-v2&envId=queue&difficulty=EASY

class CQueue {
private:
    stack<int> A, B;
public:
    CQueue() {

    }

    void appendTail(int value) {
        A.push(value);

    }

    int deleteHead() {
        if (!B.empty())
        {
            int ret = B.top();
            B.pop();
            return ret;
        }
        if (A.empty()) return -1;
        while (!A.empty())
        {
            int temp = A.top();
            A.pop();
            B.push(temp);
        }
        int ret = B.top();
        B.pop();
        return ret;
    }
};

/**
 * Your CQueue object will be instantiated and called as such:
 * CQueue* obj = new CQueue();
 * obj->appendTail(value);
 * int param_2 = obj->deleteHead();
 */
